<template>
  <div>
     <city-header></city-header>
     <city-search :cities="cities"></city-search>
     <city-list :cities="cities" :hotcity="hot" :letter="letter"></city-list>
    <city-aside :cities="cities" @change="cityChange"></city-aside>
  </div>
</template>

<script>
import axios from 'axios'
import CityHeader from './components/header.vue'
import CitySearch from './components/Search.vue'
import CityList from './components/List.vue'
import CityAside from './components/Aside.vue'
export default {
  name: 'City',
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityAside
  },
  data () {
    return {
      cities: {}, // 存储城市列表
      hot: [], // 存储热门城市
      letter: ''
    }
  },
  methods: {
    getCityInfo () {
      axios.get('./static/city.json').then(this.getInfoSucc)
    },
    getInfoSucc (res) {
      res = res.data
      if (res.ret && res.data) {
        const data = res.data
        this.cities = data.cities
        this.hot = data.hotCities
        console.log(data.cities)
      }
    },
    cityChange (letter) {
    //  console.log(letter)
      this.letter = letter
    }
  },
  mounted () {
    this.getCityInfo()
  }
}

</script>
<style scoped>

</style>
